←Select platform

Process(LEADDocument,IList<PageAlignment>) Method

Summary

Performs field processing on the LEADDocument object.

Syntax
C#
C++/CLI
Python
public void Process( 
   LEADDocument leadDoc, 
   IList<PageAlignment> formAlignment 
) 
public:  
   void Process( 
      LEADDocument^ leadDoc, 
      IList<PageAlignment^>^ formAlignment 
   ) 
def Process(self,leadDoc,formAlignment): 

Parameters

leadDoc

The LEADDocument object.

formAlignment

A value that indicates the Form Alignment. It aligns the Master Form's fields to this form field. If it is null, the fields will be aligned based on the image resolution.

Example

C#
Java
using Leadtools; 
using Leadtools.Barcode; 
using Leadtools.Codecs; 
using Leadtools.Forms.Common; 
using Leadtools.Ocr; 
using Leadtools.Forms.Processing; 
using Leadtools.Forms.Recognition; 
using Leadtools.Forms.Recognition.Barcode; 
using Leadtools.Forms.Recognition.Ocr; 
using Leadtools.Document; 
 
public void ProcessLEADDoc() 
{ 
   string masterAtt = Path.Combine(LEAD_VARS.ImagesDir, @"Forms\MasterForm Sets\OCR\FFC-107.bin"); 
   string masterFields = Path.Combine(LEAD_VARS.ImagesDir, @"Forms\MasterForm Sets\OCR\FFC-107.xml"); 
 
   RasterCodecs codecs = new RasterCodecs(); 
 
   FormProcessingEngine processingEngine = new FormProcessingEngine(); 
   FormRecognitionEngine recognitionEngine = new FormRecognitionEngine(); 
   FormRecognitionAttributes attributes = recognitionEngine.CreateForm(null); 
   FormRecognitionAttributes masterAttributes = new FormRecognitionAttributes(); 
 
   // Set Master Form Data from file and load fields 
   masterAttributes.SetData(File.ReadAllBytes(masterAtt)); 
   processingEngine.LoadFields(masterFields); 
 
   // Dropout any green pixels in the page 
   FormDropoutColor dropColor = new FormDropoutColor(0, 20, 0, 0, 230, 0); 
   processingEngine.Pages[0].DropoutColors.AddDropoutColor(dropColor); 
 
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      ocrEngine.Startup(codecs, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
      OcrObjectsManager objectsManager = new OcrObjectsManager(ocrEngine); 
      objectsManager.Engine = ocrEngine; 
 
      recognitionEngine.ObjectsManagers.Add(objectsManager); 
 
      // Load the LEADDocument from file with default options 
      LoadDocumentOptions loadOptions = new LoadDocumentOptions(); 
      LEADDocument leadDoc = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, @"Forms\Filled Forms\FCC-107_OCR_Filled.tif"), loadOptions); 
 
      // Add the lead document to the attributes object to compare 
      recognitionEngine.OpenForm(attributes); 
      recognitionEngine.AddFormPage(0, attributes, leadDoc, null, null); 
      recognitionEngine.CloseForm(attributes); 
 
      // Compare master attributes with form attributes 
      FormRecognitionResult recognitionResult = recognitionEngine.CompareForm(masterAttributes, attributes, null); 
      if (recognitionResult.PageResults.Count == 0) 
      { 
         Console.WriteLine("Pages count is 0."); 
         return; 
      } 
 
      Console.WriteLine("LEADDoc recognized with confidence of {recognitionResult.PageResults[0].Confidence}\n"); 
 
      List<PageAlignment> pageAlignments = new List<PageAlignment>(); 
      pageAlignments.Add(recognitionResult.PageResults[0].Alignment); 
 
      processingEngine.OcrEngine = ocrEngine; 
      // Process first page  
      processingEngine.Process(leadDoc, 0, 0, pageAlignments); 
 
      leadDoc.Dispose(); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
 
import static org.junit.Assert.assertTrue; 
 
import java.io.File; 
import java.io.FileNotFoundException; 
import java.io.IOException; 
import java.nio.file.Files; 
import java.nio.file.Path; 
import java.nio.file.Paths; 
import java.util.ArrayList; 
import java.util.Scanner; 
import java.util.UUID; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
 
import leadtools.*; 
import leadtools.ocr.*; 
import leadtools.codecs.*; 
import leadtools.document.*; 
import leadtools.forms.common.*; 
import leadtools.forms.processing.*; 
import leadtools.forms.recognition.*; 
import leadtools.forms.recognition.ocr.OcrObjectsManager; 
 
 
/*public void FormProcessingEngineProcessLEADDocExample() throws Exception { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   final String OCR_LEAD_RUNTIME_DIR = "C:\\LEADTOOLS23\\Bin\\Common\\OcrLEADRuntime"; 
   String masterAtt = combine(LEAD_VARS_IMAGES_DIR, "Forms\\MasterForm Sets\\OCR\\FFC-107.bin"); 
   String masterFields = combine(LEAD_VARS_IMAGES_DIR, "Forms\\MasterForm Sets\\OCR\\FFC-107.xml"); 
 
   RasterCodecs codecs = new RasterCodecs(); 
   FormProcessingEngine processingEngine = new FormProcessingEngine(); 
   FormRecognitionEngine recognitionEngine = new FormRecognitionEngine(); 
   FormRecognitionAttributes attributes = recognitionEngine.createForm(null); 
   FormRecognitionAttributes masterAttributes = new FormRecognitionAttributes(); 
 
   // Set Master Form Data from file and load fields 
   masterAttributes.setData(Files.readAllBytes(Paths.get(masterAtt))); 
   processingEngine.loadFields(masterFields); 
 
   // Dropout any green pixels in the page 
   FormDropoutColor dropColor = new FormDropoutColor(0, 20, 0, 0, 230, 0); 
   processingEngine.getPages().get(0).getDropoutColors().addDropoutColor(dropColor); 
 
   OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD); 
   ocrEngine.startup(codecs, null, null, OCR_LEAD_RUNTIME_DIR); 
   OcrObjectsManager objectsManager = new OcrObjectsManager(ocrEngine); 
   objectsManager.setEngine(ocrEngine); 
 
   recognitionEngine.getObjectsManagers().add(objectsManager); 
 
   // Load the LEADDocument from file with default options 
   LoadDocumentOptions loadOptions = new LoadDocumentOptions(); 
 
   RasterImage pageOneDoc = codecs 
         .load(combine(LEAD_VARS_IMAGES_DIR, "Forms\\Forms to be Recognized\\OCR\\FCC-107_OCR_Filled.tif"), 1); 
   RasterImage pageTwoDoc = codecs 
         .load(combine(LEAD_VARS_IMAGES_DIR, "Forms\\Forms to be Recognized\\OCR\\FCC-107_OCR_Filled.tif"), 2); 
 
   LEADDocument leadDoc = DocumentFactory.loadFromFile( 
         combine(LEAD_VARS_IMAGES_DIR, "Forms\\Forms to be Recognized\\OCR\\FCC-107_OCR_Filled.tif"), loadOptions); 
 
   // Add the lead document to the attributes object to compare 
   // open the form attributes if and only if they have not been instantiated in 
   // this file recognitionEngine.openForm(attributes); 
   recognitionEngine.addFormPage(attributes, pageOneDoc, null); 
   recognitionEngine.addFormPage(attributes, pageTwoDoc, null); 
   recognitionEngine.closeForm(attributes); 
 
   // Compare master attributes with form attributes 
   FormRecognitionResult recognitionResult = recognitionEngine.compareForm(masterAttributes, attributes, null); 
   if (recognitionResult.getPageResults().size() == 0) { 
      System.out.println("Pages count is 0."); 
      return; 
   } 
 
   System.out.println( 
         "LEADDoc recognized with confidence of " + recognitionResult.getPageResults().get(0).getConfidence()); 
 
   ArrayList<PageAlignment> pageAlignments = new ArrayList<PageAlignment>(); 
   pageAlignments.add(recognitionResult.getPageResults().get(0).getAlignment()); 
 
   processingEngine.setOcrEngine(ocrEngine); 
 
   // Process first page 
   processingEngine.process(leadDoc, 0, 0, pageAlignments); 
   pageOneDoc.dispose(); 
}*/ 

Requirements

Target Platforms

See Also

FormProcessingEngine Class

FormProcessingEngine Members

Leadtools.Forms.Processing Namespace

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Forms.Processing Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.